package com.leyou.goodsDetail.controller;

import com.leyou.goodsDetail.service.GoodsDetailService;
import com.leyou.goodsDetail.service.GoodsHtmlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * @author shkstart
 * @create 2020-04-28 20:38
 */
@Controller
@RequestMapping("item")
public class GoodsDetailController {

    @Autowired
    private GoodsDetailService goodsDetailService;
    @Autowired
    private GoodsHtmlService goodsHtmlService;

    @GetMapping("{id}.html")
    public String getItem(@PathVariable("id") Long id, Model model){
        Map<String,Object> map = goodsDetailService.buildGoodsSetail(id);
        model.addAllAttributes(map);

        goodsHtmlService.asyncExcute(id);

        return "item";
    }

}
